home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 3 of 3 / CHAPTE10 / NUMRINGS / LINE.C < prev    next >
C/C++ Source or Header  |  1996-04-28  |  25KB  |  779 lines

  1.  
  2. #include <windows.h> 
  3. #include <windowsx.h> 
  4. #include "line.h" 
  5. #include "tapi.h"
  6.  
  7. #define BUFSIZE 256
  8. #define APIHIVERSION     0x00010028    /* 1.40 */
  9. #define APILOWVERSION    0x00010000    /* 1.0 */
  10. #define EXTHIVERSION     0x00010005    /* 1.5 */
  11. #define EXTLOWVERSION    0x00000009    /* 0.9 */ 
  12. #define OWNER        0
  13. #define MONITOR      1
  14. #define MAX_CALL        3
  15. #define MAX_LINE        2
  16.  
  17.  
  18. #if defined (WIN32)
  19.     #define IS_WIN32 TRUE
  20. #else
  21.     #define IS_WIN32 FALSE
  22. #endif
  23.  
  24. #define IS_NT      IS_WIN32 && (BOOL)(GetVersion() < 0x80000000)
  25. #define IS_WIN32S  IS_WIN32 && (BOOL)(!(IS_NT) && (LOBYTE(LOWORD(GetVersion()))<4))
  26. #define IS_WIN95   (BOOL)(!(IS_NT) && !(IS_WIN32S)) && IS_WIN32
  27.  
  28. LPCTSTR lpszAppName = "lineGetNumRings";
  29. LPCTSTR lpszTitle   = "lineGetNumRings"; 
  30.  
  31. HINSTANCE hInst;   // current instance
  32. HWND hWnd;         // parent window handle
  33. HWND hListWnd;     // listbox
  34. HDC  hdc;
  35. TEXTMETRIC  tm ;
  36.  
  37. BOOL RegisterWin95( CONST WNDCLASS* lpwc );
  38.  
  39.  
  40. int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
  41.                       LPTSTR lpCmdLine, int nCmdShow)
  42. {
  43.    MSG      msg;
  44.    WNDCLASS wc;
  45.  
  46.    wc.style         = CS_HREDRAW | CS_VREDRAW;
  47.    wc.lpfnWndProc   = (WNDPROC)WndProc;       
  48.    wc.cbClsExtra    = 0;                      
  49.    wc.cbWndExtra    = 0;                      
  50.    wc.hInstance     = hInstance;              
  51.    wc.hIcon         = LoadIcon (hInstance, lpszAppName); 
  52.    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  53.    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  54.    wc.lpszMenuName  = lpszAppName;              
  55.    wc.lpszClassName = lpszAppName;              
  56.  
  57.    if ( IS_WIN95 )
  58.    {
  59.       if ( !RegisterWin95( &wc ) )
  60.          return( FALSE );
  61.    }
  62.    else if ( !RegisterClass( &wc ) )
  63.       return( FALSE );
  64.  
  65.    hInst = hInstance; 
  66.  
  67.    hWnd = CreateWindow( lpszAppName, 
  68.                         lpszTitle,    
  69.                         WS_OVERLAPPEDWINDOW, 
  70.                         CW_USEDEFAULT, 0, 
  71.                         CW_USEDEFAULT, 0,  
  72.                         NULL,              
  73.                         NULL,              
  74.                         hInstance,         
  75.                         NULL               
  76.                       );
  77.  
  78.    if ( !hWnd ) 
  79.       return( FALSE );
  80.  
  81.    ShowWindow( hWnd, nCmdShow ); 
  82.    UpdateWindow( hWnd );         
  83.  
  84.    while( GetMessage( &msg, NULL, 0, 0) )   
  85.    {
  86.       TranslateMessage( &msg ); 
  87.       DispatchMessage( &msg );  
  88.    }
  89.  
  90.    return( msg.wParam ); 
  91. }
  92.  
  93.  
  94. BOOL RegisterWin95( CONST WNDCLASS* lpwc )
  95. {
  96.     WNDCLASSEX wcex;
  97.  
  98.    wcex.style         = lpwc->style;
  99.    wcex.lpfnWndProc   = lpwc->lpfnWndProc;
  100.    wcex.cbClsExtra    = lpwc->cbClsExtra;
  101.    wcex.cbWndExtra    = lpwc->cbWndExtra;
  102.    wcex.hInstance     = lpwc->hInstance;
  103.    wcex.hIcon         = lpwc->hIcon;
  104.    wcex.hCursor       = lpwc->hCursor;
  105.    wcex.hbrBackground = lpwc->hbrBackground;
  106.    wcex.lpszMenuName  = lpwc->lpszMenuName;
  107.    wcex.lpszClassName = lpwc->lpszClassName;
  108.  
  109.    // Added elements for Windows 95.
  110.    //...............................
  111.    wcex.cbSize = sizeof(WNDCLASSEX);
  112.    wcex.hIconSm = LoadImage(wcex.hInstance, lpwc->lpszClassName, 
  113.                             IMAGE_ICON, 16, 16,
  114.                             LR_DEFAULTCOLOR );
  115.             
  116.    return RegisterClassEx( &wcex );
  117. }
  118.  
  119. #define CONFCALL    1
  120. #define CONSULT      2
  121.  
  122. enum CallState
  123. {
  124.     Idle,
  125.     Offering,
  126.     Accepted,
  127.     Dialtone,
  128.     Dialing,
  129.     Ringback,
  130.     Busy,
  131.     Special,
  132.     Connected,
  133.     Proceeding,
  134.     Conferenced,
  135.     Onholdconf,
  136.     Disconnected,
  137.     Unknown
  138. };
  139.  
  140. typedef struct tagMYINFO      // general application information
  141. {
  142.     HLINEAPP lineApp;         // instance handle TAPI gives back to us                                                                              through lineInitialize()
  143.     DWORD dwNumDevices;       // number of available devices
  144.     DWORD dwAPIVersion;       // API version the line supports
  145.      DWORD dwExtVersion;           // extended version
  146.     char szLocation[128];     // location        
  147.      char szCallingCard[128];  // calling card being used
  148.     char szAreaCode[4];       // area code       
  149.     char szCountry[128];      // calling card being used
  150. } MYINFO;
  151.  
  152. typedef struct tagLINEINFO  // information on an open line
  153. {
  154.     DWORD dwNumAddress;     // number of available addresses on the line 
  155.     HLINE hLine;            // handle to the line as returned by lineOpen 
  156.      DWORD dwLineID;         // the line ID of this line
  157.     char  szLineName[128];  // the line's name 
  158.  
  159. } MYLINEINFO;
  160.  
  161. typedef struct tagMYCALLINFO  //information on a call                     
  162. {
  163.     
  164. DWORD       eCallState;    // TAPI's line call State, set as user-defined enums
  165. DWORD      dwRequestID;   // requestID returned by async TAPI functions lineMakeCall/lineDropCall
  166. DWORD      dwAddressID;   // the originating address ID of the call being made 
  167. LPCSTR     lpszAddress;    
  168. HLINE     hLine;         // handle to the line 
  169. HCALL        hCall;         // handle to the call 
  170.    
  171. char szDialString[TAPIMAXDESTADDRESSSIZE];  //phone number being dialed
  172. char szDialStringOriginal[TAPIMAXDESTADDRESSSIZE];
  173. char szDialStringCanonical[TAPIMAXDESTADDRESSSIZE];
  174. char szCalledParty[TAPIMAXCALLEDPARTYSIZE]; // name of the party
  175. DWORD dwTranslateResults;
  176.         
  177. } MYCALLINFO;
  178.  
  179. enum CallAction     // Declare enum type CallAction (used in lineSetAppSpecific)
  180. {
  181.    HOLD,            // hold the call
  182.    TRANSFER,        // transfer the call
  183.    REDIRECT,        // redirect the call
  184.    DROP,            // drop the call
  185.    PARK             // park the call
  186. }; 
  187.  
  188. MYINFO myInfo;          //instance of MYINFO structure
  189. MYLINEINFO myLineInfo[MAX_LINE];  //instance of MYLINEINFO structure
  190. MYCALLINFO myCallInfo[MAX_CALL]; //array of MYCALLINFO strcuture
  191.  
  192. LONG lRet;        //return code
  193. char buf[BUFSIZE];    // buffer for debug message
  194.  
  195. DWORD dwLineID = 0;
  196. DWORD i;
  197. LINEEXTENSIONID        ext_id;
  198. LINEDEVCAPS            *plineDevCaps;
  199. LINEADDRESSCAPS        *plineAddressCaps;
  200. LINEADDRESSSTATUS     *plineAddressStat;
  201. LINECALLINFO            *plineCallInfo;
  202. LINECALLSTATUS         *plineCallStatus;
  203. LINECALLLIST            *plineCallList;
  204. LINEDEVSTATUS           *plineDevStatus;
  205. LINETRANSLATECAPS       *plineTranslateCaps;
  206. LINETRANSLATEOUTPUT  *plineTranslateOutput;
  207. LINECALLPARAMS           *plineCallParams;
  208. LINEDEVSTATUS           *plineDevStatus;
  209. LINEFORWARDLIST        *plineForwardList;
  210. LINETRANSLATECAPS       *plineTranslateCaps;
  211. LINEREQMAKECALL       lineReqMakeCall;
  212. VARSTRING               *pDeviceConfig;
  213. VARSTRING               *pDeviceId;
  214. VARSTRING               *pNonDirAddress;
  215.  
  216. LPLINELOCATIONENTRY  lineLocEntry;
  217. LPLINECARDENTRY        lineCardEntry;
  218. LINECOUNTRYLIST         *plineCountryList;
  219. LPLINECOUNTRYENTRY   lineCE;
  220.  
  221. LPSTR                lpData;
  222.  
  223. HICON                hIcon = NULL;        //used in lineGetID();
  224. DWORD                dwNumRings;    //used in lineGetNumRings();
  225. HCALL                hConsultCall; //handle to consultation linePrepareAddToConference, SetupConference
  226. HCALL                hConfCall; //handle to consultation linePrepareAddToConference, SetupConference   
  227. HCALL                hParkedCall;
  228.  
  229. DWORD                dwCompletionID;  //used in lineCompleteCall()
  230.  
  231. char                szName[128];
  232. char                szNumber[128];
  233. char                szDigits[128];
  234. char                szDevConfig[128];
  235.  
  236. LONG lRet;
  237. char buf[BUFSIZE];
  238.  
  239. LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  240. {
  241.    switch( uMsg )
  242.    {
  243.       case WM_COMMAND :
  244.          switch( LOWORD( wParam ) )
  245.          {
  246.             case IDM_RUN :
  247.                // set the number of rings to for all calls on the line that this
  248.                // address
  249.                //................................
  250.                lRet = lineSetNumRings (myLineInfo[0].hLine,  
  251.                                        myCallInfo[0].dwAddressID, 4);
  252.                
  253.                if (lRet == 0)
  254.                {
  255.                   wsprintf (buf, "lineSetNumRings succeeded!");
  256.                   SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  257.                }
  258.                else 
  259.                {
  260.                   wsprintf ( buf,"lineSetNumRings failed, err=x%lx", lRet);
  261.                   lineError(lRet);
  262.                   break;
  263.                }
  264.  
  265.                //lineGetNumRings
  266.                //...................................................
  267.                lRet = lineGetNumRings(myLineInfo[0].hLine,
  268.                                        myCallInfo[0].dwAddressID, &dwNumRings);
  269.                if (lRet == 0)
  270.                {
  271.                  wsprintf (buf, "lineGetNumRings succeeded!");
  272.                  SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  273.                  wsprintf( buf,"The number of rings for all calls on this line is: x%lx", dwNumRings);
  274.                  SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  275.                }
  276.                else 
  277.                {
  278.                   wsprintf ( buf,"lineGetNumRings failed, err=x%lx", lRet);
  279.                   lineError(lRet);
  280.                }
  281.                
  282.                break;
  283.          
  284.             case IDM_ABOUT :
  285.             {
  286.                 DialogBox( hInst, "AboutBox", hWnd, (DLGPROC)About );
  287.                break;
  288.             }
  289.  
  290.             case IDM_EXIT :
  291.             {
  292.                for (i = 0; i < myInfo.dwNumDevices; i++)
  293.                        lineClose(myLineInfo[i].hLine);
  294.                     lineShutdown(myInfo.lineApp);
  295.                DestroyWindow( hWnd );
  296.                break;
  297.             }
  298.             }                  
  299.                  
  300.          break;
  301.  
  302.       case WM_CREATE :
  303.       {
  304.          hdc = GetDC (hWnd) ;
  305.          GetTextMetrics (hdc, &tm) ;
  306.          ReleaseDC (hWnd, hdc) ;
  307.  
  308.          hListWnd = CreateWindowEx( 0, "listbox", 
  309.                         " ",    
  310.                         WS_CHILD | WS_VISIBLE,  
  311.                         tm.tmAveCharWidth, tm.tmHeight * 3, 
  312.                         tm.tmAveCharWidth * 16 +
  313.                                    GetSystemMetrics (SM_CXVSCROLL), 
  314.                         tm.tmHeight * 5,  
  315.                         hWnd,              
  316.                         NULL,              
  317.                         hInst,         
  318.                         NULL               
  319.                         );
  320.  
  321.          
  322.          //lineInitialize
  323.             //...............................................
  324.          lRet = lineInitialize(&myInfo.lineApp, hInst, lineCallback, NULL, &myInfo.dwNumDevices);
  325.          if (lRet == 0) 
  326.          {
  327.             wsprintf (buf, "lineInitialize suceeded!");
  328.               SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  329.            }
  330.          else 
  331.           {
  332.                wsprintf ( buf,"lineInitialize failed, err=x%lx",lRet);
  333.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  334.                lineError(lRet);
  335.                break;
  336.          }                    
  337.          
  338.          //lineNegotiateAPIVersion
  339.           //...............................................
  340.          lRet = lineNegotiateAPIVersion(myInfo.lineApp, 0, APILOWVERSION, APIHIVERSION, 
  341.                                            &myInfo.dwAPIVersion, &ext_id);
  342.          if (lRet == 0)                        
  343.          {
  344.             wsprintf (buf, "lineNegotiateAPIVersion suceeded!");
  345.               SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  346.          }
  347.          else 
  348.           {
  349.                wsprintf (buf, "lineNegotiateAPIVersion failed, err=x%lx",
  350.                            lRet);
  351.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  352.                lineError(lRet);
  353.                lineShutdown (myInfo.lineApp);
  354.             break;
  355.          }
  356.  
  357.           //lineNegotiateExtVersion
  358.           //...............................................
  359.          lRet = lineNegotiateExtVersion(myInfo.lineApp, 0, myInfo.dwAPIVersion, EXTLOWVERSION, 
  360.                                            EXTHIVERSION, &myInfo.dwExtVersion);
  361.          if (lRet == 0)                        
  362.          {
  363.             wsprintf (buf, "lineNegotiateExtVersion suceeded!");
  364.             SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  365.  
  366.          }
  367.           else 
  368.           {
  369.                wsprintf (buf, "lineNegotiateExtVersion failed, err=x%lx",
  370.                      lRet);
  371.               SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  372.               lineError(lRet);
  373.       
  374.          }
  375.  
  376.           //lineGetDevCaps
  377.           //for each line device, get capabilities until we find one that supports
  378.          //interactive voice 
  379.           //...............................................
  380.          plineDevCaps = (LINEDEVCAPS *) calloc (1, sizeof(LINEDEVCAPS)+1000);
  381.          plineDevCaps->dwTotalSize = sizeof(LINEDEVCAPS) + 1000;
  382.          for (i = 0; i < myInfo.dwNumDevices; i++)
  383.          {
  384.             lineGetDevCaps(myInfo.lineApp, i, myInfo.dwAPIVersion, 0, plineDevCaps);
  385.             if (plineDevCaps->dwMediaModes & LINEMEDIAMODE_INTERACTIVEVOICE) 
  386.             {
  387.                
  388.                myLineInfo[i].dwNumAddress = plineDevCaps->dwNumAddresses;
  389.                   myLineInfo[i].dwLineID = i;
  390.                    if (plineDevCaps->dwLineNameSize > 0)
  391.                           strcpy(myLineInfo[i].szLineName,((LPSTR)(plineDevCaps)+plineDevCaps->dwLineNameOffset));
  392.              }
  393.           }
  394.  
  395.          //lineOpen
  396.           //................................................................
  397.           lRet = lineOpen(myInfo.lineApp,myLineInfo[OWNER].dwLineID,&myLineInfo[OWNER].hLine,
  398.                            myInfo.dwAPIVersion,0,(DWORD)lineCallback, LINECALLPRIVILEGE_NONE,
  399.                             LINEMEDIAMODE_DATAMODEM, NULL);
  400.           if (lRet == 0)
  401.           {
  402.             wsprintf (buf, "lineOpen suceeded!");
  403.             SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;         }
  404.            else 
  405.            {
  406.                wsprintf ( buf,"lineOpen failed, err=x%lx", lRet);
  407.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  408.                lineError(lRet);
  409.           }
  410.        
  411.          break;
  412.       }
  413.       
  414.       case WM_SIZE:
  415.           MoveWindow(hListWnd,0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
  416.          break;
  417.  
  418.       case WM_DESTROY :
  419.               PostQuitMessage(0);
  420.               break;
  421.  
  422.       default :
  423.             return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
  424.    }
  425.  
  426.    return( 0L );
  427. }
  428.  
  429.  
  430.  
  431.  
  432. /****************************************************************************
  433.     FUNCTION: lineCallback
  434.     PURPOSE:  callback function handles line events
  435. ****************************************************************************/
  436. LRESULT CALLBACK lineCallback (DWORD dwDevice, DWORD dwMsg,
  437.                                        DWORD dwCallbackInst, DWORD dwParam1,
  438.                                        DWORD dwParam2,DWORD dwParam3)
  439. {
  440.    switch (dwMsg)
  441.    {
  442.       case LINE_CALLSTATE:
  443.        {
  444.             for (i = 0; i < MAX_CALL; i++)
  445.            {
  446.                 if (dwDevice = (DWORD) myCallInfo[i].hCall) 
  447.                  switch (dwParam1)
  448.                  {
  449.                     case LINECALLSTATE_IDLE:
  450.                         myCallInfo[i].eCallState = Idle;
  451.                   break;
  452.                     
  453.                     case LINECALLSTATE_OFFERING:
  454.                   myCallInfo[i].eCallState = Offering;
  455.                   break;
  456.                                    
  457.                     case LINECALLSTATE_ACCEPTED:
  458.                         myCallInfo[i].eCallState = Accepted;
  459.                         break;
  460.                     
  461.                     case LINECALLSTATE_DIALTONE:
  462.                         myCallInfo[i].eCallState = Dialtone;
  463.                   break;
  464.                     
  465.                     case LINECALLSTATE_DIALING:
  466.                         myCallInfo[i].eCallState = Dialing;
  467.                         break;
  468.                   
  469.                   case LINECALLSTATE_RINGBACK:
  470.                         myCallInfo[i].eCallState = Ringback;
  471.                         break;
  472.             
  473.                     case LINECALLSTATE_BUSY:
  474.                         myCallInfo[i].eCallState = Busy;
  475.                         break;
  476.             
  477.                     case LINECALLSTATE_SPECIALINFO:
  478.                         myCallInfo[i].eCallState = Special;
  479.                        break;
  480.             
  481.                     case LINECALLSTATE_CONNECTED:
  482.                        myCallInfo[i].eCallState = Connected;
  483.                   break;
  484.  
  485.                     case LINECALLSTATE_PROCEEDING:
  486.                         myCallInfo[i].eCallState = Proceeding;
  487.                        break;
  488.             
  489.                     case LINECALLSTATE_CONFERENCED:
  490.                         myCallInfo[i].eCallState = Conferenced;
  491.                        break;
  492.             
  493.                     case LINECALLSTATE_ONHOLDPENDCONF:
  494.                         break;
  495.                 
  496.                case LINECALLSTATE_DISCONNECTED:
  497.                         myCallInfo[i].eCallState = Disconnected;
  498.                        break;
  499.             
  500.                     case LINECALLSTATE_UNKNOWN:
  501.                         myCallInfo[i].eCallState = Unknown;
  502.                        break;
  503.        
  504.              }
  505.           }
  506.        }
  507.  
  508.        case LINE_MONITORMEDIA:
  509.            break;
  510.  
  511.        case LINE_MONITORDIGITS:
  512.           break;
  513.  
  514.          case LINE_MONITORTONE:
  515.           break;
  516.    
  517.        //error handling for functions completed asynchronously
  518.         //.....................................................
  519.        case LINE_REPLY:
  520.         {
  521.             for (i = 0; i < MAX_CALL; i++)
  522.            {
  523.                 if (dwParam1 = myCallInfo[i].dwRequestID)
  524.                {
  525.                    if (dwParam2 != 0)
  526.                    {
  527.                        lineError((LONG) dwParam2);
  528.                        break;
  529.                    }
  530.                }
  531.            }
  532.         break;
  533.         }
  534.  
  535.         case LINE_GENERATE:
  536.           break;
  537.      
  538.        case LINE_REQUEST:
  539.          break;
  540.  
  541.         case LINE_GATHERDIGITS:
  542.            break;
  543.    }
  544.  
  545.    return (TRUE);
  546.  
  547.  
  548. /****************************************************************************
  549.     FUNCTION: lineError
  550.     PURPOSE:  line error messages
  551. ****************************************************************************/
  552. void lineError (LONG lrc)
  553. {
  554.  switch (lrc) {
  555.     case LINEERR_INVALAPPHANDLE:
  556.        MessageBox (hWnd, "Invalid app handle.", "", MB_OK);
  557.        break;
  558.     case LINEERR_BADDEVICEID:
  559.        MessageBox (hWnd,"The specified line device ID is out of range.", "", 
  560.                    MB_OK);
  561.        break;
  562.     case LINEERR_INCOMPATIBLEAPIVERSION:
  563.        MessageBox (hWnd, "Incompatible API version.", "", MB_OK);
  564.        break;
  565.     
  566.     case LINEERR_ADDRESSBLOCKED:
  567.        MessageBox (hWnd, "Address was blocked.", "", MB_OK);
  568.        break;
  569.  
  570.     case LINEERR_BEARERMODEUNAVAIL:
  571.        MessageBox (hWnd, "Bearer Mode Unavailable.", "", MB_OK);
  572.        break;
  573.  
  574.     case LINEERR_CALLUNAVAIL:
  575.        MessageBox (hWnd, "Call appearances in use..", "", MB_OK);
  576.        break;
  577.  
  578.     case LINEERR_INUSE:
  579.        MessageBox (hWnd, "Line in Use.", "", MB_OK);
  580.        break;
  581.     
  582.     case LINEERR_INVALADDRESS:
  583.        MessageBox (hWnd, "Invalid Address.", "", MB_OK);
  584.        break;
  585.  
  586.     case LINEERR_INVALADDRESSID:
  587.        MessageBox (hWnd, "Invalid Address ID.", "", MB_OK);
  588.        break;
  589.  
  590.     case LINEERR_INVALCALLPARAMS:
  591.        MessageBox (hWnd, "Invalid Address ID.", "", MB_OK);
  592.        break;
  593.      
  594.     case LINEERR_INCOMPATIBLEEXTVERSION:
  595.        MessageBox (hWnd, "Incompatible extension version.","", MB_OK);
  596.        break;
  597.     case LINEERR_NOMEM:
  598.        MessageBox (hWnd, "No memory","", MB_OK);
  599.        break;
  600.     case LINEERR_NODRIVER:
  601.        MessageBox (hWnd, "No driver loaded", "", MB_OK);
  602.        break;
  603.     case LINEERR_RESOURCEUNAVAIL:
  604.        MessageBox (hWnd, "Resource overcommittment", "", MB_OK);
  605.        break;
  606.     case LINEERR_INVALPRIVSELECT:
  607.        MessageBox (hWnd, "Requested invalid priviledges", "", MB_OK);
  608.        break;
  609.     case LINEERR_INVALMEDIAMODE:
  610.        MessageBox (hWnd, "Requested invalid media mode", "", MB_OK);
  611.        break;
  612.     case LINEERR_LINEMAPPERFAILED:
  613.        MessageBox (hWnd, "Line mapper failed", "", MB_OK);
  614.        break;
  615.     case LINEERR_INVALPOINTER:
  616.        MessageBox (hWnd, "The specified pointer parameter is invalid.",
  617.                    "", MB_OK);
  618.        break;
  619.     case LINEERR_OPERATIONFAILED:
  620.        MessageBox (hWnd, "Operation failed.", "", MB_OK);
  621.        break;
  622.     case LINEERR_INVALLINEHANDLE:
  623.        MessageBox (hWnd, "Invalid line handle", "", MB_OK);
  624.        break;
  625.     case LINEERR_INVALCALLHANDLE:
  626.        MessageBox (hWnd, "Invalid call handle", "", MB_OK);
  627.        break;
  628.     case LINEERR_INVALCALLSELECT:
  629.        MessageBox (hWnd, "Invalid call selection", "", MB_OK);
  630.        break;
  631.     case LINEERR_NODEVICE:
  632.        MessageBox (hWnd, "No associated device for given class",
  633.                    "", MB_OK);
  634.        break;
  635.     case LINEERR_OPERATIONUNAVAIL:
  636.        MessageBox (hWnd, "The operation is unavailable",
  637.                    "", MB_OK);
  638.        break;
  639.     case LINEERR_INVALPARAM:
  640.         MessageBox(hWnd, "Invalid Paramater", "", MB_OK);
  641.        break; 
  642.  
  643.     case LINEERR_TARGETNOTFOUND:
  644.         MessageBox(hWnd, "Target Not Found", "", MB_OK);
  645.        break; 
  646.  
  647.    case LINEERR_NOREQUEST:
  648.       MessageBox(hWnd, "No outstanding Assisted Telephony requests.", "", MB_OK);
  649.        break; 
  650.    }
  651. }
  652.  
  653. LRESULT CALLBACK Dial ( HWND hDlg,           // window handle of the dialog box
  654.                         UINT message,        // type of message
  655.                         WPARAM wParam,       // message-specific information
  656.                         LPARAM lParam)
  657. {
  658.    switch (message) 
  659.    {
  660.        case WM_INITDIALOG:  // message: initialize dialog box
  661.                return (TRUE);
  662.  
  663.        case WM_COMMAND:                              // message: received a command
  664.          if (   LOWORD(wParam) == IDOK )        // "OK" box selected?
  665.          {
  666.             GetDlgItemText(hDlg, IDC_NAME, szName, 128);
  667.                 GetDlgItemText(hDlg, IDC_NUMBER, szNumber, 128);
  668.                                       
  669.  
  670.                 // put up a dialog box to obtain a string to dial from the user
  671.                //...........................................................
  672.                strcpy(myCallInfo[0].szDialStringOriginal, szNumber); 
  673.                
  674.                //allocate buffer for the LINEADDRESSCAPS strucuture 
  675.                //...................................................
  676.                plineTranslateOutput = (LINETRANSLATEOUTPUT *) calloc (1, sizeof(LINETRANSLATEOUTPUT)+1000);
  677.             plineTranslateOutput->dwTotalSize = sizeof(LINETRANSLATEOUTPUT) + 1000;
  678.               
  679.                // translate the Address to a dialable address and Canonical address
  680.                //.....................................................................
  681.                lRet = lineTranslateAddress(myInfo.lineApp, myLineInfo[OWNER].dwLineID, myInfo.dwAPIVersion,
  682.                                            myCallInfo[0].szDialStringOriginal, 0, 0, plineTranslateOutput);
  683.                               
  684.                if (lRet == 0)
  685.                {
  686.                        
  687.                    strncpy(myCallInfo[0].szDialString, (LPSTR)(plineTranslateOutput)
  688.                             + plineTranslateOutput->dwDialableStringOffset,
  689.                              plineTranslateOutput->dwDialableStringSize); 
  690.     
  691.                     strncpy(myCallInfo[0].szDialStringCanonical,(LPSTR)(plineTranslateOutput) 
  692.                             + plineTranslateOutput->dwDisplayableStringOffset,
  693.                             plineTranslateOutput->dwDisplayableStringSize); 
  694.                                            
  695.                    myCallInfo[0].dwTranslateResults = plineTranslateOutput->dwTranslateResults;
  696.                 }
  697.  
  698.                else 
  699.                {
  700.                     wsprintf ( buf,"lineTranslateAddress failed, err=x%lx", lRet);
  701.                     lineError(lRet);
  702.                    break;
  703.             }
  704.            
  705.                //lineMakeCall
  706.                //................................................................
  707.                           
  708.                plineCallParams = (LINECALLPARAMS *) calloc (1, sizeof(LINECALLPARAMS)+1000);
  709.             plineCallParams->dwTotalSize = sizeof(LINECALLPARAMS) + 1000;
  710.  
  711.                plineCallParams->dwBearerMode = LINEBEARERMODE_VOICE;
  712.                plineCallParams->dwMediaMode =  LINEMEDIAMODE_DATAMODEM;
  713.                plineCallParams->dwCallParamFlags = LINECALLPARAMFLAGS_IDLE;
  714.                plineCallParams->dwAddressMode    = LINEADDRESSMODE_ADDRESSID;
  715.                plineCallParams->dwAddressID    = 0;
  716.                plineCallParams->dwMinRate    = 1200;
  717.                plineCallParams->dwMaxRate    = 2400;
  718.                             
  719.                lRet = lineMakeCall(myLineInfo[OWNER].hLine,&myCallInfo[0].hCall, 
  720.                                       myCallInfo[0].szDialString ,0,  plineCallParams);
  721.            
  722.             if (lRet > 0)
  723.                {
  724.                wsprintf (buf, "lineMakeCall suceeded!");
  725.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;               
  726.                    myCallInfo[0].dwRequestID = lRet;
  727.                 }
  728.             else 
  729.                {
  730.                    wsprintf ( buf,"lineMakeCall failed, err=x%lx", lRet);
  731.                     lineError(lRet);
  732.                    break;
  733.             }
  734.             
  735.             EndDialog(hDlg, TRUE);        // Exit the dialog
  736.             return (TRUE);
  737.          }
  738.  
  739.             if (   LOWORD(wParam) == IDCANCEL)         // "OK" box selected?
  740.          {
  741.             EndDialog(hDlg, TRUE);        // Exit the dialog
  742.             return (TRUE);
  743.          }
  744.          break;
  745.  
  746.  
  747.    }
  748.  
  749.    return (FALSE); 
  750. }
  751.  
  752.  
  753. LRESULT CALLBACK About( HWND hDlg,           
  754.                         UINT message,        
  755.                         WPARAM wParam,       
  756.                         LPARAM lParam)
  757. {
  758.    switch (message) 
  759.    {
  760.        case WM_INITDIALOG: 
  761.                return (TRUE);
  762.  
  763.        case WM_COMMAND:                              
  764.                if (   LOWORD(wParam) == IDOK         
  765.                    || LOWORD(wParam) == IDCANCEL)    
  766.                {
  767.                        EndDialog(hDlg, TRUE);        
  768.                        return (TRUE);
  769.                }
  770.                break;
  771.    }
  772.  
  773.    return (FALSE); 
  774. }
  775.  
  776.  
  777.  
  778.